﻿@page "/mine"
@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MyAppBar>
    <MToolbarTitle Class="font-weight-bold">
        @(I18n.T("Mine.Mine"))
    </MToolbarTitle>
    <MSpacer></MSpacer>
    <MultiSearch OnSearch="Search"></MultiSearch>
</MyAppBar>

<ScrollContainer @ref="scrollContainer">
    <div class="d-sm-flex flex-sm-row justify-space-between">
        <MCard Class="setting-info mb-5 py-sm-3 py-md-5 elevation-sm-2--active"
               Elevation="0"
               Rounded="@("lg")"
               Ripple="false"
               OnClick="@(()=>To("user"))">
            <MList>
                <MListItem ThreeLine>
                    <MListItemAvatar Class="ml-sm-2 ml-md-4 mr-md-6"
                                     Rounded="@("lg")"
                                     Size="70">
                        <img class="user-avatar" src="@(avatar)" @onclick="()=>showPreviewImage=true" @onclick:stopPropagation="true" />
                    </MListItemAvatar>
                    <MListItemContent>
                        <MListItemTitle Class="text-h6 font-weight-bold">
                            @(userName ?? I18n.T("AppName"))
                        </MListItemTitle>
                        <MListItemSubtitle>
                            @(sign ?? I18n.T("Mine.Sign"))
                        </MListItemSubtitle>
                    </MListItemContent>
                    <MListItemAction Style="align-self:unset;">
                        <MIcon>mdi-chevron-right</MIcon>
                    </MListItemAction>
                </MListItem>
            </MList>
        </MCard>

        <MCard Class="setting-info mb-5 ml-sm-5 d-flex"
               Elevation="0"
               Rounded="@("lg")">
            <MList Class="d-flex flex-grow-1">
                <MListItem>
                    <MListItemContent Class="justify-space-around text-center">
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Statistics.DiaryCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @diaryCount
                            </MListItemTitle>
                        </div>
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Statistics.WordCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @wordCount
                            </MListItemTitle>
                        </div>
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Statistics.ActiveDayCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @activeDayCount
                            </MListItemTitle>
                        </div>
                    </MListItemContent>
                </MListItem>
            </MList>
        </MCard>
    </div>

    @foreach (var list in ViewLists)
    {
        <div class="text-h6 setting-title">
            @(I18n.T(list.Key))
        </div>

        <MCard @key="list"
               Class="list-item-card"
               Elevation="0"
               Rounded="@("lg")">
            <MList Class="dynamic-list-item-collection">
                @foreach (var item in list.Value)
                {
                    <MListItem @key="item"
                               OnClick="item.OnClick">
                        <MListItemIcon>
                            <MIcon Class="list-item-icon">
                                @(item.Icon)
                            </MIcon>
                        </MListItemIcon>
                        <MListItemContent>
                            @(I18n.T(item.Text))
                        </MListItemContent>
                        <MListItemAction>
                            <MIcon>mdi-chevron-right</MIcon>
                        </MListItemAction>
                    </MListItem>

                    <MDivider Class="mx-3"></MDivider>
                }

            </MList>
        </MCard>
    }

</ScrollContainer>

<RadioDialog @bind-Value="language"
             @bind-Visible="showLanguage"
             Title="@(I18n.T("Mine.SelectLanguage"))"
             OnChange="LanguageChanged"
             TItem="KeyValuePair<string,string>"
             TItemValue="string"
             Items="I18n.Languages">
</RadioDialog>

<RadioDialog @bind-Value="theme"
             @bind-Visible="showTheme"
             Title="@(I18n.T("Mine.Night"))"
             OnChange="ThemeChanged"
             TItem="KeyValuePair<string,Shared.Theme>"
             TItemValue="Shared.Theme"
             Items="themeItems">
</RadioDialog>

<MultiListDialog @bind-Visible="showFeedback"
                 Title="@(I18n.T("Mine.ContactWay"))"
                 DynamicListItems="FeedbackTypes">
</MultiListDialog>

<PreviewImageDialog @bind-Visible="showPreviewImage"
                    Src="@avatar">
</PreviewImageDialog>
